<template>
	<view class="" :style="'background:'+bgdata.bg_color+';'+skin">
		<jnavbar :PageId="1" :title="title" :bgdata="bgdata"></jnavbar>
		<toptabs  v-if="toptabs && tab_id != 0" :mydata="toptabs"></toptabs>
		<block v-if="tab_id == 0">
			<renovation v-for="(item, i) in list" :mydata="item.data" :key="i"></renovation>
			<renovation v-for="(item, index) in list1" :mydata="item.data" :key="item.name"></renovation>
		</block>
		<block v-else><custompage ref="mycustom"></custompage></block>
		<copyright></copyright>
		<!-- {{isload}} -->
		<u-gap height="60"></u-gap>
		<tab-bar ref="tabbar" :PageId="1"></tab-bar>
		<floatmenu page_id="0"></floatmenu>
		<trolley></trolley>
		<uni-login ref="Login" @callback="logincallback"></uni-login>
		<receive></receive>
		<renovation v-if="advs && advs.type" :mydata="advs"></renovation>
		<view class="sign_div" v-if="sign_show" @click="Jumpurl(sign_link)">
			<vimage @click="Jumpurl(sign_link)" mode="widthFix" imgtype="1" src="static/images/sign1.png"></vimage>
		</view>
	</view>
</template>
<script>
import renovation from '@/components/renovation/index.vue';
import receive from '@/components/receive/index.vue';
import copyright from '@/components/copyrights/index.vue';
import custompage from '@/components/custompage/custompage.vue';
import {mapState, mapMutations} from 'vuex';
import toptabs from '@/components/renovation/Basics/toptabs.vue';
export default {
	data() {
		return {
			isload:false,
			list: [],
			list1: [],
			scrollTop: 0,
			loading: true,
			title: '',
			sign_show: false,
			sign_link: {
				link: '/marketpage/marketing/signin',
				type: 1,
				login_type: 2
			},
			advs: {},
			toptabs: {},
			bgdata: {}
			// skin:getApp().globalData.skin
		};
	},
	components: {
		renovation,
		receive,
		copyright,
		custompage,
		toptabs
	},
	computed: {
		...mapState({
			hastabbar: state => state.hastabbar,
			tab_id: state => state.tab_id,
			skin: state => state.skin
		})
	},
	watch:{
		tab_id(){
			this.changtab(this.tab_id)
		}
	},
	onshow(){
	
	},
	onShareAppMessage() {
		return this.wxShare();
	},
	onPullDownRefresh() {
		this.getRenovation();
	},
	async onLoad(e) {
		// this.isload=true
		await  this.$getWx
		// #ifdef MP-WEIXIN
		wx.showShareMenu({
		  withShareTicket: false,
		  menus: ['shareAppMessage', 'shareTimeline']
		})
		// #endif
		
		this._freshing = false;

		if (e.id && e.is_preview) {
			this.id = e.id;
			this.is_preview = 1;
		}
		this.sign_show = uni.getStorageSync('is_remind');
		this.getRenovation();
		this.getadvert();
		this.getjuris('mallBase').then(res => {});
		
	},
	onShow() {
		
		// this.$nextTick(a => {
		// 	_this.$refs.tabbar.gettabs();
		// });
	},
	methods: {
		onRefresh() {
			this.getRenovation();
		},
		changtab(i) {
			let _this = this;
			this.$nextTick(function() {
				if (i > 0) {
					let id = _this.toptabs.list[i].linkdata.id;

					_this.$refs.mycustom.custompage(id);
				}
			});
		},
		onFinish() {},
		onPublicShare() {},
		getadvert() {
			this.$http('/renovation/advert', {}, 'GET').then(res => {
				let data = JSON.parse(res.data.msg);
				this.advs = data;
			});
		},
		getRenovation() {
			var data = {
				type: 1
			};
			if (this.is_preview) {
				data.is_preview = this.is_preview;
				data.id = this.id;
			}
			this.$http('/Renovation/getRenovationInfo', data, 'GET').then(res => {
				uni.stopPullDownRefresh();
				if (res.statusCode == 200) {
					let data = res.data;
					let configure = JSON.parse(data.msg);
					this.bgdata = configure.page_config;
					console.log(configure)
					
					this.list = configure.list;
					// if (this.list[0] && this.list[0].name == 'toptabs') {
					// 	this.toptabs = this.list[0].data;
					// 	this.list.splice(0, 1);
					// }
					let i = this.list.findIndex(_ => _.name == 'toptabs');
					if (i > -1) {
						this.toptabs = this.list[i].data;
						if(this.tab_id!=0){
							this.changtab(this.tab_id)
						}
						// this.list.splice(0, 1);
					}
					uni.setNavigationBarTitle({
						title: configure.page_data.nav_name
					});
					this.title = configure.page_data.nav_name;
					if (configure.list1) {
						this.list1 = configure.list1;
					}
					// if (configure.advs) {
					// 	this.advs = configure.advs;
					// }

					this.$store.commit('setGid', this.$u.guid());
					this.changeloading({loading: false});

					// this.changeloading(false)
				}
			});
		},
		logincallback(e) {
			if (e.islogin) {
				this.addstaff();
			}
		}
	}
};
</script>

<style lang="scss" scoped>
.banner {
	width: 720rpx;
	height: 200rpx;
	margin-bottom: 20rpx;
	margin-left: 15rpx;
}
.list {
	padding: 32rpx;
	.item {
		width: 330rpx;
		height: 400rpx;
		margin-top: 10rpx;
	}
}
.sign_div {
	position: fixed;
	right: 0;
	width: 180rpx;
	bottom: 200rpx;
	z-index: 10000;
	image {
		width: 180rpx;
	}
	.icon {
		position: absolute;
		left: -15rpx;
		font-size: 40rpx;
		z-index: 10001;
		top: -15rpx;
	}
}
</style>
